<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$basic=$this->plugin_setting('basic');
//我的收藏
if($_RQ['op']=='main'){
	$return['list']=array();
	$return['params']=array();
	$return['sum']=$sum;
	exi($return);

}
if($_RQ['op']=='getlist'){
	$ids=pdo_getall('jy_quan_shoucang',array('uniacid'=>$_SESSION['uniacid'],'isshoucang'=>1,'mid'=>$_SESSION['uid']),array('pid'),'pid');
	$ids=array_keys($ids);
	//按点赞数排序作品
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($ids){
		$params['id']=$ids;
	}
	if($_RQ['keyword']){
		if(is_numeric($_RQ['keyword'])){
			$params['id']=intval($_RQ['keyword']);
			$return['params']['id']=intval($_RQ['keyword']);
		}else{
			$params['title like']='%'.$_RQ['keyword'].'%';
			$return['params']['title']=$_RQ['keyword'];
		}
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$list=pdo_getslice('jy_quan_item',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		foreach($list as &$item){
			$item['jielinum']=pdo_count('jy_quan_item_jieli',array('uniacid'=>$_SESSION['uniacid'],'pid'=>$item['id']),'id');
			$item['member']=pdo_get('core_members',array('id'=>$item['mid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','avatar','nickname'));
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='del'){
	$id = intval($_RQ['id']);
	if(!$id){
		exi('帖子不存在哦！','error');
	}
	pdo_delete('jy_quan_shoucang',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'pid'=>$id));
	exi('删除成功！');

}
